<include file="public@header" />
<style>
    .table tr > td.active, .table tr > th.active, .table tr.active > td, .table tr.active > th , .table tr.active td, .table-hover > tbody > tr.active:hover > td{
        background-color: #5081D6;
        color: #fff;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <form class="well form-inline margin-top-20" method="get" action="{:url('taxi/chooseDriver')}">
        <input type="hidden" name="order_no" value="{$order_no}">
        <input type="text" class="form-control w-300" name="keyword" value="{:input('request.keyword/s','')}" placeholder="请输入 关键词">
        <input type="submit" class="btn btn-primary" value="搜索" />
    </form>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th width="100">姓名</th>
            <th width="120">司机编号</th>
            <th width="200">车牌号</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="list" item="vo" key="key">
            <tr class="list-item" data-key="{$key}">
                <td>{$vo.name}</td>
                <td>{$vo.code}</td>
                <td>{$vo.car_no}</td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <button class="btn btn-primary col-12 accept">确定配车</button>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    var list = {$list|json_encode};
    var order_no = '{$order_no}';
    // 选择
    $('.list-item').click(function () {
        $(this).siblings().removeClass('active').end().addClass('active');
    });

    // 确定
    $('.accept').click(function () {

        var rowObj = $('.list-item.active');

        if(rowObj.length == 0) {
            layer.msg('请选择司机');
            return;
        }

        var key = rowObj.data('key');
        var data = list.data[key];
        data.order_no = order_no;

        $.post('{:url("taxi/chooseDriverAccept")}', data, function () {
            var index = parent.layer.getFrameIndex(window.name);
            window.parent.layer.close(index);
            window.parent.location.reload();
        });

    });
</script>
</body>
</html>